package cn.silver.framework.log.enums;

import cn.silver.framework.core.model.DictModel;
import cn.silver.framework.core.utils.StreamUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;

/**
 * 业务操作类型
 *
 * @author Silver Zhou
 */
@Getter
@AllArgsConstructor
public enum OperateEnums {
    /**
     *
     */
    SEAR_ALL("sear_all", "查询全部数据", OperateTypeEnums.OPER_SEARCH.getCode()),
    SEAR_PAGE("sear_page", "分页列表查询", OperateTypeEnums.OPER_SEARCH.getCode()),
    SEAR_VIEW("sear_view", "查看数据详情", OperateTypeEnums.OPER_SEARCH.getCode()),
    SEAR_RECYCLE("sear_recycle", "查看已删除数据", OperateTypeEnums.OPER_SEARCH.getCode()),
    SEAR_COUNT("sear_count", "查看数据总数", OperateTypeEnums.OPER_SEARCH.getCode()),
    SEAR_TREE("sear_tree", "查询树结构数据", OperateTypeEnums.OPER_SEARCH.getCode()),
    SEAR_ROOT("sear_root", "查询根节点数据", OperateTypeEnums.OPER_SEARCH.getCode()),
    SEAR_CHILD("sear_child", "查询子节点数据", OperateTypeEnums.OPER_SEARCH.getCode()),
    ALTER_CHECK("alter_check", "数据保存前校验", OperateTypeEnums.OPER_ALTER.getCode()),
    ALTER_SAVE("alter_save", "保存数据", OperateTypeEnums.OPER_ALTER.getCode()),
    ALTER_UPDATE("alter_update", "修改数据", OperateTypeEnums.OPER_ALTER.getCode()),
    ALTER_DELETE("alter_delete", "删除数据", OperateTypeEnums.OPER_ALTER.getCode()),
    ALTER_REMOVE("alter_remove", "彻底删除数据", OperateTypeEnums.OPER_ALTER.getCode()),
    ALTER_RESTORE("alter_restore", "还原已删除数据", OperateTypeEnums.OPER_ALTER.getCode()),
    ALTER_CLEAR("alter_clear","清空缓存",OperateTypeEnums.OPER_ALTER.getCode()),
    ALTER_SYNC("alter_sync", "数据同步", OperateTypeEnums.OPER_ALTER.getCode()),
    OSS_EXPORT("data_export", "数据导出", OperateTypeEnums.OPER_FILE.getCode()),
    OSS_IMPORT("data_import", "导入数据", OperateTypeEnums.OPER_FILE.getCode()),
    OSS_GENERATE("data_generate", "代码生成", OperateTypeEnums.OPER_FILE.getCode()),
    OSS_UPLOAD("oss_upload", "文件上传", OperateTypeEnums.OPER_FILE.getCode()),
    OSS_DOWNLOAD("oss_download", "文件下载", OperateTypeEnums.OPER_FILE.getCode()),
    OSS_PREVIEW("oss_preview", "文件预览", OperateTypeEnums.OPER_FILE.getCode()),
    OSS_SHARE("oss_share", "文件分享", OperateTypeEnums.OPER_FILE.getCode()),
    OSS_REPEAT("oss_repeat", "保存分享的文件", OperateTypeEnums.OPER_FILE.getCode()),
    OSS_RENAME("oss_rename", "文件重命名", OperateTypeEnums.OPER_FILE.getCode()),
    OSS_COPY("oss_copy", "复制文件", OperateTypeEnums.OPER_FILE.getCode()),
    OSS_MOVE("oss_move", "文件移动", OperateTypeEnums.OPER_FILE.getCode()),
    OSS_UNZIP("oss_unzip", "文件解压缩", OperateTypeEnums.OPER_FILE.getCode()),
    OSS_ZIP("oss_zip", "压缩文件", OperateTypeEnums.OPER_FILE.getCode()),
    FLOW_SUBMIT("flow_submit", "流程提交", OperateTypeEnums.OPER_ALTER.getCode()),
    FLOW_APPROVE("flow_approve", "流程审批", OperateTypeEnums.OPER_ALTER.getCode()),
    FLOW_REMINDER("flow_reminder", "流程催办", OperateTypeEnums.OPER_ALTER.getCode()),
    FLOW_SUSPEND("flow_suspend", "流程挂起", OperateTypeEnums.OPER_ALTER.getCode()),
    FLOW_UNHOOK("flow_unhook", "流程解挂", OperateTypeEnums.OPER_ALTER.getCode()),
    FLOW_STOP("flow_stop", "流程终止", OperateTypeEnums.OPER_ALTER.getCode()),
    SYS_FORCE("force", "强行登出系统", OperateTypeEnums.OPER_OTHER.getCode()),
    OTHER("other", "其他操作", OperateTypeEnums.OPER_OTHER.getCode());
    /**
     * 编码
     */
    private final String code;
    /**
     * 名称
     */
    private final String name;
    private final String group;

    public static List<DictModel> getModels() {
        return StreamUtils.toList(Arrays.asList(values()), item -> new DictModel(item.name, item.code));
    }
}
